<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/24 0024
 * Time: 下午 2:26
 */
namespace app\common\model;

use app\admin\controller\Base;
use think\Db;
use think\Model;

class BaseModel extends Model{
    protected $resultSetType = 'collection';
    const STATUS_INVALID = 0;  //状态  无效
    const STATUS_VALID = 1;  //状态  有效
    const STATUS_DELETE = 2; //状态  删除
    const STAUTS_LOWER_FRAME = 3; //状态下架
    private $offset = 15;
    public function select_all($whereOption = array(),$page,$limit){

        if($limit <0 || $limit == null){
            $limit = $this->offset;
        }

        if(!$page){
            $page = 0;
        }

       /* if($isrelation){
            $result->relation($relation);
        }*/
            $result = self::where($whereOption)->limit($limit)->page($page)->select();
       if($result&&!empty($result)){
           $count = self::where($whereOption)->limit($limit)->page($page)->count();
       }else{
           $count = 0;
       }

        $list = array(
            "count"=>$count,
            "list"=>$result,
            "currentPage"=>$page,
            "start"=>$page+1
        );
            return $list;
    }
}